<template>
  <div class="dashboard-container">
    <div class="dashboard-text">name: {{ name }}</div>

    <div id="main" style="width: 800px;height: 400px" ></div>
  </div>
</template>

<script>
import {mapGetters} from 'vuex'
import * as echarts from 'echarts';
import {xx} from '@/api/user'

export default {
  name: 'Dashboard',
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  data(){
    return{
      teacherName:[],
      total:[],
    }
  },
  created() {
    xx().then(res=>{
      this.teacherName=res.data.teacherName
      this.total=res.data.playCount

      var chartDom = document.getElementById('main');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        xAxis: {
          type: 'category',
          data: this.teacherName
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: this.total,
            type: 'line'
          }
        ]
      };

      option && myChart.setOption(option);
    })
  },
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
